class CNC

	#Does your machine have automatic tool changing
	HasToolChanger = true
	
	#A list of tools if your machine has a tool changer. Some whitespace after the first
	#keeps the UI looking nice for some reason.
	Tools = ["1: Cuchilla 18         ",
	         "2: 45 Graus",
	    	 "3: Rodo",
	    	 "4: Positiva 10",
	    	 "5: Positiva 3",
	    	 "6: Cuchilla 16"]
	    	 
	#Is your machine equipped with drill bits
	HasDrills = true
	
	#this is the path where your CNC machine will find the CNC files.
	#It is used for the joblist.  In my case, I use a floppy disc.  Cutting edge!
	Path = File.join("a:")	
	
	#most machines have a maximum number of lines they can post process
	#if you dont know, set it to 1 million or so.
	MaxLines = 1000
			
	#How do your programs start?  You can include workpiece information
	def self.programStart(workpiece)
		line1 = "G71" + "X" + workpiece.x +
						"Y" + workpiece.y +
						"Z" + workpiece.z +
						"T00"
		line2 = "G150()A0B0C0"
		return [line1, line2]
	end
	
	#How do your programs end?  I like to include an offset that I can specify on 
	#the workshop floor
	def self.programEnd(workpiece)
		line1 = "G92G54P5Z=cY=bX=a"
		line2 = "M2"
		return [line1, line2]
	end	
	
	#This generates a list of programs to perform.  It's not really necessary but it
	#does make the whole producton process more agile
	def self.listItem(program)
		workpiece = program.workpiece
		if workpiece.x.to_f > 1300
		  area = "N"
		else
		  area = "S"
		end
		if program.face == 6
			comment = "Reverse!"
		else
			comment = ""
		end
		line = program.path + ";" +
			   "1;" +
			   area +
			   ";0;1;" +
			   	workpiece.x + ";" +
			   	workpiece.y + ";" +
			   	workpiece.z + ";" +
				comment + ";" + 
				"0;0;0;0;0;0;0;;;;;;"
		return line
	end
	
	
	#Ignore the following.  They just fetch class variables	
	def self.hasToolChanger?; return HasToolChanger end
	def self.tools; return Tools end
	def self.hasDrills?; return HasDrills end
	def self.path; return Path end
	def self.maxLines; return MaxLines end
end
puts "CNC OK"